from django.db import models
from django.contrib.auth.models import AbstractUser


class User(AbstractUser):
    """自定义用户模型类"""
    GENDER_CHOICES = (
        ('0', "男"),
        ('1', "女"),
        ('2', "保密"))

    mobile = models.CharField(max_length=11, unique=True, verbose_name='手机号')
    email_active = models.CharField(max_length=6, default="1", verbose_name='邮箱验证状态')
    is_vip = models.IntegerField(default=0, verbose_name='vip')
    gender = models.CharField(max_length=6, choices=GENDER_CHOICES, default="2", verbose_name="性别")
    city = models.CharField(max_length=20, null=True, blank=True, verbose_name="城市")
    signature = models.CharField(max_length=255, null=True, blank=True, verbose_name="签名")
    images_url = models.CharField(max_length=255,
                                  default="http://q2fyx80nw.bkt.clouddn.com/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg",
                                  verbose_name="头像")
    award = models.IntegerField(default=0, verbose_name='用户的飞吻数')
    continuous_sign_in = models.IntegerField(default=0, verbose_name="用户连续签到的天数")
    T_F_sign = models.CharField(max_length=20, default="0", verbose_name="今日可签到")

    class Meta:
        db_table = 'tb_users'
        verbose_name = '用户'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.username


class Fans(models.Model):
    """定义关注模型类"""

    users = models.ForeignKey(User, related_name='users', verbose_name='用户')
    parentss = models.ForeignKey(User, related_name='userss', verbose_name='父类用户')
    is_deleted = models.BooleanField(default=False, verbose_name='逻辑删除')

    class Meta:
        db_table = 'tb_fans'
        verbose_name = '关注'
        verbose_name_plural = verbose_name
